#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int n, m;
unordered_map<int, int>  my_map;

bool check(int hmax)
{
    int sum = 0;
    for (auto x : my_map) {
        int b = x.second;
        sum += b / hmax + (b % hmax == 0 ? 0 : 1);
    }
    return sum <= m;
}


int main()
{
    cin >> n >> m;

    int maxCount = 0;
    for (int i = 0; i < n; i++) {

        int num;
        cin >> num;

        my_map[num]++;

        maxCount = max(my_map[num], maxCount);
    }

    if (my_map.size() > m) {
        cout << -1;
    }
    else {


        int left = 1, right = maxCount;
        while (left < right) {

            int mid = (left + right) / 2;

            if (check(mid)) {
                right = mid;
            }
            else {
                left = mid + 1;
            }
        }

        cout << right << endl;
    }


    return 0;
}